package com.fs.console.base.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fs.common.baseMapper.ConfigMapper;
import com.fs.common.pojo.Config;
import com.fs.console.base.enums.ConfigType;
import com.fs.console.base.vo.BasicsConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ACE
 * @desc 后台基础数据业务类
 * @creationTime 2019-04-03 22:55
 * @projectName weixinframe
 * @packageName com.fs.base.service
 */
@Service
public class ConsoleService {
    @Autowired
    private ConfigMapper configMapper;
    /**
     * 获取配置文件
     * @return
     */
    public BasicsConfig getConfig() {
        BasicsConfig basicsConfig = new BasicsConfig();
        QueryWrapper<Config> wrapper = new QueryWrapper<>();
        wrapper.eq("groups", ConfigType.BASICS.getMsg());
        List<Config> list = configMapper.selectList(wrapper);
        for (Config config:list) {
            if("systemName".equals(config.getName())){
                basicsConfig.setSystemName(config.getValue());
            }else if("systemAbbreviation".equals(config.getName())){
                basicsConfig.setSystemavia(config.getValue());
            }else if("copyright".equals(config.getName())){
                basicsConfig.setCopyright(config.getValue());
            }else if("version".equals(config.getName())){
                basicsConfig.setVersion(config.getValue());
            }
        }
        return basicsConfig;
    }
}
